package ls.jpa.chapterD.repository.impl;

import ls.jpa.chapterD.value.BookValue;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;

/**
 * @author barudisshu
 */
public class AuthorDaoImpl {

    @PersistenceContext
    private EntityManager em;

    public List<BookValue> findBookValue(){
        Query query = em.createNativeQuery("SELECT b.id, b.title, b.version, CONCAT(a.firstName, ' ', a.lastName) as authorName FROM Book b JOIN Author a ON b.author_id = a.id","bookValue");
        return query.getResultList();
    }

}
